package org.example.service.impl;

import org.example.service.GoodsService;
import org.example.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Service;

@Service("orderService")
public class OrderServiceImpl implements OrderService {


    GoodsService  goodsService;

    public OrderServiceImpl(GoodsService goodsService) {
        this.goodsService = goodsService;
    }

    public GoodsService getGoodsService() {
        return goodsService;
    }


    public void setGoodsService(GoodsService goodsService) {
        this.goodsService = goodsService;
    }

    @Override
    public void buy() {
        goodsService.goodsDetail();
        System.out.println("购买商品");
    }

    public static void main(String[] args) {
        ApplicationContext context =new ClassPathXmlApplicationContext("applicationContext.xml");
        OrderService orderService =(OrderService) context.getBean("orderService");
        orderService.buy();

    }
}
